#
# Copyright (C) 2004-2008 National Institute of Advanced Industrial
# Science and Technology (AIST), Japan.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version
# 2 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
PACKAGE		:= @PACKAGE_STRING@
KERNELRELEASE	:= $(shell uname -r)
LIBNL		:= @LIBNL@
LIBNL_DIR	:= @LIBNL_DIR@

INSTALL		:= @INSTALL@
INSTALL_PROGRAM	:= @INSTALL_PROGRAM@
INSTALL_SCRIPT	:= @INSTALL_SCRIPT@
INSTALL_DATA	:= @INSTALL_DATA@

all:
	$(MAKE) -C kernel
	$(MAKE) -C tc
ifeq ($(LIBNL), yes)
	$(MAKE) -C $(LIBNL_DIR)
	$(MAKE) -C pspd
endif

docs:
	$(MAKE) -C doc

install:
	$(MAKE) -C kernel install DESTDIR=$(DESTDIR)
	$(MAKE) -C tc install DESTDIR=$(DESTDIR)
	$(MAKE) -C man install DESTDIR=$(DESTDIR)
ifeq ($(LIBNL), yes)
	$(MAKE) -C $(LIBNL_DIR) install DESTDIR=$(DESTDIR)
	$(MAKE) -C pspd install DESTDIR=$(DESTDIR)
endif

docs-install:
	$(MAKE) -C doc install DESTDIR=$(DESTDIR)

dist:	distclean
	(cd scripts; ./mkpkg.sh -o ../$(PACKAGE).tar.gz)

clean:
	$(MAKE) -C kernel clean
	$(MAKE) -C tc clean
ifeq ($(LIBNL), yes)
	$(MAKE) -C $(LIBNL_DIR) clean
endif
	$(MAKE) -C pspd clean
	$(MAKE) -C doc clean
	find  . -name "*~" | xargs rm -f
	find  . -name ".#*" | xargs rm -f

distclean: clean
	find . -name "Makefile" | xargs rm -f
	rm -f config.log config.options config.status
	rm -rf autom*
	rm -f README.en.html
	rm -f $(PACKAGE).tar.gz
